import theAxios from 'axios'
// 进度条
import Nprogress from 'nprogress'
import 'nprogress/nprogress.css'

const MockAxios = theAxios.create({
  baseURL: 'https://www.test.com',
  timeout: 5000
})

MockAxios.interceptors.request.use(config => {
  // 进度条开始
  Nprogress.start()
  return config
}, error => {
  return Promise.reject(error)
})

MockAxios.interceptors.response.use(response => {
  // 进度条结束
  Nprogress.done()
  return response.data
}, error => {
  alert(error.message)
  return new Promise(() => {
  })
})

export default MockAxios
